/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
package org.ice.module;

import java.lang.reflect.Method;

import org.ice.exception.IceException;
import org.ice.http.HttpRequest;
import org.ice.http.HttpResponse;

public interface IModule {
	
	public void setRequest(HttpRequest request);
	
	public HttpRequest getRequest();
	
	/**
	 * Lifecycle callback method
	 * Called just after the controller has been initialized
	 * You should do some variables initialization only
	 */
	public void init();
	
	/**
	 * Lifecycle callback method
	 * Called before the request is dispatched
	 * You should do some filterings/validations only
	 */
	public void preDispatch(Method method) throws Exception;
	
	/**
	 * Lifecycle callback method
	 * Dispatch the request
	 * @throws IceException 
	 */
	public void dispatch(String task) throws Exception;
	
	/**
	 * Lifecycle callback method
	 * Called after the request is dispatched
	 * You should do some stuffs which are common in all request
	 */
	public void postDispatch(Method method) throws Exception;
	
	/**
	 * Get the response generated by this module
	 * @return the response
	 */
	public String getStreamResponse();
	
	/**
	 * Lifecycle callback method
	 * Called just before the request finished
	 */
	public void destroy();

	public HttpResponse getResponse();
	
	public void setResponse(HttpResponse response);
	
}
